package com.quinn.myDemo.lever;

import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * Balance
 *
 * @author HanQuinn
 * Date: 2025/10/11
 * Time: 13:36
 */
@Data
public class Balance {

    /**
     * 本金
     */
    private BigDecimal capitalBalance;

    /**
     * 负债
     */
    private BigDecimal debtBalance = new BigDecimal("0");

    /**
     * 持股手数
     */
    private BigDecimal holdHands;

    /**
     * 股价
     */
    private BigDecimal price;

    /**
     * 总资产
     *
     * @return
     */
    public BigDecimal getTotalPrice() {
        return holdHands.multiply(new BigDecimal("100")).multiply(price).setScale(4, RoundingMode.HALF_UP);
    }

    /**
     * 净资产
     *
     * @return
     */
    public BigDecimal getNetBalance() {
        return getTotalPrice().subtract(debtBalance).setScale(4, RoundingMode.HALF_UP);
    }

    /**
     * 利润
     *
     * @return
     */
    public BigDecimal getProfitBalance() {
        return getTotalPrice().subtract(debtBalance).subtract(capitalBalance).setScale(4, RoundingMode.HALF_UP);
    }

    public Balance() {
    }

    /**
     * // 本金capitalBalance, 负债debtBalance, 持股手数holdHands, 股价price
     * @param capitalBalance
     * @param debtBalance
     * @param holdHands
     * @param price
     */
    public Balance(BigDecimal capitalBalance, BigDecimal debtBalance, BigDecimal holdHands, BigDecimal price) {
        this.capitalBalance = capitalBalance;
        this.debtBalance = debtBalance;
        this.holdHands = holdHands;
        this.price = price;
    }
}
